home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Mathematics / Notebooks / URichMultivariateCalculus / 03 / Lab3.ma next >
Encoding:
Text File  |  1992-08-19  |  15.2 KB  |  219 lines

  1. (*^
  2.  
  3. ::[paletteColors = 128; currentKernel; 
  4.     fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e8,  24, "Times"; ;
  5.     fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e6,  18, "Times"; ;
  6.     fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, L1, e6,  14, "Times"; ;
  7.     fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, L1, a20,  18, "Times"; ;
  8.     fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, L1, a15,  14, "Times"; ;
  9.     fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, L1, a12,  12, "Times"; ;
  10.     fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  11.     fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  10, "Times"; ;
  12.     fontset = input, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L1,  12, "Courier"; ;
  13.     fontset = output, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5,  12, "Courier"; ;
  14.     fontset = message, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1,  12, "Courier"; ;
  15.     fontset = print, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1,  12, "Courier"; ;
  16.     fontset = info, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1,  12, "Courier"; ;
  17.     fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, L1,  12, "Courier"; ;
  18.     fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, L1,  10, "Times"; ;
  19.     fontset = header, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  20.     fontset = Left Header, nohscroll, cellOutline,  12;
  21.     fontset = footer, inactive, nohscroll, noKeepOnOnePage, preserveAspect, center, M7, L1,  12;
  22.     fontset = Left Footer, cellOutline, blackBox,  12;
  23.     fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  10, "Times"; ;
  24.     fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  25.     fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12, "Courier"; ;
  26.     fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  27.     fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  28.     fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  29.     fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  30.     fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  31.     next21StandardFontEncoding; ]
  32. :[font = title; inactive; Cclosed; preserveAspect; startGroup; ]
  33. Lab 3: Surfaces
  34. :[font = section; inactive; Cclosed; preserveAspect; startGroup; ]
  35. Introduction
  36. :[font = text; inactive; preserveAspect; endGroup; ]
  37. In two-dimensional analytic geometry, the simplest curves can be represented as graphs of functions of one variable.  In three-dimensional analytic geometry, the simplest surfaces can be represented as graphs of functions of two variables.  This notebook explores such surfaces.
  38. :[font = section; inactive; Cclosed; preserveAspect; startGroup; ]
  39. The Plot3D Command
  40. :[font = text; inactive; preserveAspect; ]
  41. The Plot3D command is used to draw the graphs of functions of two variables.
  42. ;[s]
  43. 3:0,0;3,1;11,2;77,-1;
  44. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  45. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  46. Examples
  47. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  48. Here is the graph of the function z = x^2 :
  49. ;[s]
  50. 3:0,0;33,1;42,2;44,-1;
  51. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  52. :[font = input; preserveAspect; ]
  53. Plot3D[ x^2, {x,-2,2}, {y,0,3} ];
  54. :[font = text; inactive; preserveAspect; endGroup; ]
  55. Mathematica knows that the expression x^2 is a function of two variables (x and y) because we used the Plot3D command (instead of the Plot command) and because we have provided ranges for both x and y.  The notation {x,-2,2} means to graph the function for the range  -2 <= x <= 2, and the notation {y,0,3} means to graph the function for the range    0 <= y <= 3.
  56.  
  57. Notice that the perspective image shows the X-axis at the front bottom of the box running downward to the right.  The Y-axis (through the points where x=z=0)  is not drawn, but it lies in the middle of the bottom of the box running upward to the right.  The Z-axiz (through the points where x=y=0) is also not drawn; it runs upward through the middle of the front of the box.
  58.  
  59. This surface is a parabolic cylinder.  That is, it is the set of all lines perpendicular to the XZ-plane that pass through the parabola  z = x^2  in that plane.  Fifteen of these parallel lines are actually drawn on the surface.  The parabola also appears fifteen times on the surface.  
  60. ;[s]
  61. 14:0,0;11,1;37,2;42,3;102,4;110,5;133,6;139,7;215,8;225,9;298,10;307,11;761,12;779,13;1031,-1;
  62. 14:1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  63. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  64. The next example is only slightly different from the last one.
  65. :[font = input; preserveAspect; ]
  66. Plot3D[ x^2-y^2/10, {x,-2,2}, {y,-2,2} ];
  67. :[font = text; inactive; preserveAspect; endGroup; ]
  68. Here the paralllel lines (in the Y direction) have all been bent a little into parabolic arcs.  The one through the origin has the equation z = y^2 /10.  Notice that we changed the range on y to be the same as the range on x .
  69. ;[s]
  70. 3:0,0;139,1;151,2;227,-1;
  71. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  72. :[font = text; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ]
  73. The third example is like the second, except that now the upside down parabolas (in the Y direction) are more curved.  The one through the origin has the equation z = y^2 .
  74. ;[s]
  75. 3:0,0;162,1;171,2;173,-1;
  76. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  77. :[font = input; preserveAspect; endGroup; endGroup; ]
  78. Plot3D[ x^2-y^2, {x,-2,2}, {y,-2,2} ];
  79. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  80. Exercises
  81. :[font = text; inactive; preserveAspect; ]
  82. 1.  Draw the graph of the surface  z = y^2  for  0 <= x <= 5  and  -2 <= y <= 2 .
  83. :[font = text; inactive; preserveAspect; ]
  84. 2.  Draw the graph of  z = y^2 - x^2 /10  for  -2 <= x <= 2  and  -2 <= y <= 2 .
  85. :[font = text; inactive; preserveAspect; endGroup; endGroup; ]
  86. 3.  Draw the graph of  z = y^2  - x^2  for  -2 <= x <= 2  and  -2 <= y <= 2 .
  87. :[font = section; inactive; Cclosed; preserveAspect; startGroup; ]
  88. Level Curves
  89. :[font = text; inactive; preserveAspect; ]
  90. All of the surfaces drawn above are examples of hyperbolic paraboloids.  (A parabolic cylinder is a special kind of hyperbolic paraboloid.)  They are called "paraboloids" because their vertical cross-sections are parabolas.  They are called "hyperbolic" because their horizontal cross-sections are hyperbolas.  Horizontal cross-sections are also called "level curves" because each is a curve obtained by projecting onto the XY-plane all the points on the surface that are at a given level (i.e. Z-value).  Level curves are often used to produce a two-dimensional representation of a surface.
  91. ;[s]
  92. 3:0,0;48,1;70,2;592,-1;
  93. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  94. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  95. Examples
  96. :[font = text; inactive; preserveAspect; ]
  97. Mathematica uses the ContourPlot command to draw level curves.
  98. ;[s]
  99. 4:0,0;11,1;20,2;33,3;62,-1;
  100. 4:1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  101. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  102. Here's the contour plot of the third hyperbolic paraboloid shown in the previous section:
  103. :[font = input; preserveAspect; ]
  104. ContourPlot[ x^2-y^2, {x,-2,2}, {y,-2,2} ];
  105. :[font = text; inactive; preserveAspect; ]
  106. The ContourPlot command produces a topographical map, coloring the high places in lighter shades and the low places in darker shades.  The lines are the level curves.
  107. ;[s]
  108. 3:0,0;3,1;16,2;166,-1;
  109. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  110. :[font = text; inactive; preserveAspect; endGroup; ]
  111. All the curves shown in the above example are hyperbolas.  For example, the level curve at the level  z=1  on the surface would have the equation x^2 - y^2 = 1.  That is the inner-most hyperbola among those that are symmetric about the X-axis.
  112. ;[s]
  113. 3:0,0;145,1;159,2;243,-1;
  114. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  115. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  116. Here are both the surface (which is a plane) and the family of level curves for the linear function z = 2x - y :
  117. ;[s]
  118. 3:0,0;99,1;111,2;113,-1;
  119. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  120. :[font = input; preserveAspect; ]
  121. Plot3D[ 2x-y, {x,-2,2}, {y,-2,2} ];
  122. ContourPlot[ 2x-y, {x,-2,2}, {y,-2,2} ];
  123. :[font = text; inactive; preserveAspect; endGroup; ]
  124. It should not surprise you that the level curves of a plane are straight lines.
  125. :[font = text; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ]
  126. When you need to use the same function in more than one command, it is better to define the function explicitly first: 
  127. :[font = input; preserveAspect; ]
  128. f[x_,y_] := -4x/(3+x^2+y^2);
  129. Plot3D[ f[x,y], {x,-8,8}, {y,-8,8} ];
  130. ContourPlot[ f[x,y], {x,-8,8}, {y,-8,8} ];
  131. :[font = text; inactive; preserveAspect; endGroup; ]
  132. Notice that Mathematica has several peculiar requirements for functions:
  133. 1.  On the left side of the definition, the variables are written with trailing underlines.
  134. 2.  The definition requires the equal sign to be immediately preceded by a colon.
  135. 3.  Functions use square brackets  [ ]  instead of parentheses  ( ) .
  136. ;[s]
  137. 3:0,0;12,1;23,2;317,-1;
  138. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  139. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  140. In the last example, both the surface and the level curves were rather jagged.  That is because Mathematica automatically approximates curves and surfaces with line segments and flat (planar) panels, and it uses the default number of 15 in each dimension.  The rendering can be made smoother by means of the PlotPoints option:
  141. ;[s]
  142. 5:0,0;96,1;107,2;307,3;319,4;327,-1;
  143. 5:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  144. :[font = input; preserveAspect; ]
  145. Plot3D[ f[x,y], {x,-8,8}, {y,-8,8}, PlotPoints->32 ];
  146. ContourPlot[ f[x,y], {x,-8,8}, {y,-8,8}, PlotPoints->32 ];
  147. :[font = text; inactive; preserveAspect; endGroup; ]
  148. These two pictures are much smoother because we used more than twice the number of "sampling points" in each dimension.  Of course, the trade-off is that it takes Mathematica longer to draw the pictures.
  149. ;[s]
  150. 3:0,0;163,1;174,2;204,-1;
  151. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  152. :[font = text; inactive; preserveAspect; endGroup; ]
  153. Notice that once the function f is defined, it can be used thoughout your Mathematica session without having to redefine it.
  154. ;[s]
  155. 5:0,0;29,1;32,2;74,3;85,4;124,-1;
  156. 5:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  157. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  158. Exercises
  159. :[font = text; inactive; preserveAspect; ]
  160. For each of the following, (a) define the function; (b) draw its graph in the range given; (c) draw its level curves in the same range.  If the picture is not smooth enough, use the PlotPoints option to make it smoother.
  161. :[font = text; inactive; preserveAspect; ]
  162. 1.  x^3 - 3x*y^2,  -2 <= x <= 2,  -2 <= y <= 2 .
  163. :[font = text; inactive; preserveAspect; ]
  164. 2.  Sin[x^2] + y^2,  -4 <= x <= 4,  -4 <= y <= 4 .
  165. :[font = text; inactive; preserveAspect; endGroup; endGroup; ]
  166. 3.  Sin[x^2 + y^2],  -3 <= x <= 3,  -3 <= y <= 3 .
  167. :[font = section; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ]
  168. The Contours Option
  169. ;[s]
  170. 3:0,0;3,1;13,2;20,-1;
  171. 3:1,16,12,Times,1,18,0,0,0;1,14,11,Courier,1,18,0,0,0;1,16,12,Times,1,18,0,0,0;
  172. :[font = text; inactive; preserveAspect; ]
  173. The ContourPlot command has a large number of options that may be used to obtain different results.  One of the most useful is the Contours option.  It can be used to specify precisely which level curves are to be shown.
  174. ;[s]
  175. 7:0,0;3,1;16,2;130,3;140,4;185,5;190,6;223,-1;
  176. 7:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  177. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  178. Examples
  179. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  180. In this example we use the Contours -> 8 option to obtain 8 level curves:
  181. ;[s]
  182. 3:0,0;26,1;41,2;73,-1;
  183. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  184. :[font = input; preserveAspect; ]
  185. f[x_,y_] := x y Exp[-x^2-y^2];
  186. Plot3D[ f[x,y], {x,-2,2},{ y,-2,2}, PlotPoints -> 32 ];
  187. ContourPlot[ f[x,y], {x,-2,2}, {y,-2,2}, PlotPoints -> 32,
  188.              Contours -> 8];
  189. :[font = text; inactive; preserveAspect; ]
  190. And now here is the same contour plot with 16 level curves:
  191. :[font = input; preserveAspect; endGroup; ]
  192. ContourPlot[ f[x,y], {x,-2,2}, {y,-2,2}, PlotPoints -> 32,
  193.              Contours -> 16];
  194. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  195. The Contours option can also be used to specify which level curves are to be displayed.  Simply list the z-values (i.e. the levels) that you want:
  196. ;[s]
  197. 3:0,0;3,1;13,2;146,-1;
  198. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  199. :[font = input; preserveAspect; ]
  200. ContourPlot[ f[x,y], {x,-2,2}, {y,-2,2}, PlotPoints -> 32,
  201.              Contours -> {-0.1,-0.05,0,0.05,0.1,0.15,0.2} ];
  202. :[font = text; inactive; preserveAspect; endGroup; endGroup; ]
  203. This shows the horizontal cross-sections at the 7 levels: -0.1, -0.05, 0, 0.05, 0.1, 0.15, 0.2.
  204. ;[s]
  205. 3:0,0;58,1;94,2;95,-1;
  206. 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;
  207. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  208. Exercises
  209. :[font = text; inactive; preserveAspect; ]
  210. For each of the following, draw the surface and the contour plot and specific levels.
  211. :[font = text; inactive; preserveAspect; ]
  212. 1.  Sin[x + y],  -2Pi <= x <= 2Pi,  -2Pi <= y <= 2Pi .
  213. :[font = text; inactive; preserveAspect; ]
  214. 2.  Sin[x] + Sin[y],  -2Pi <= x <= 2Pi,  -2Pi <= y <= 2Pi .
  215. :[font = text; inactive; preserveAspect; ]
  216. 3.  (x^2 + 3y^2) / Exp[x^2 + y^2],   -3 <= x <= 3,  -3 <= y <= 3 .
  217. :[font = text; inactive; preserveAspect; endGroup; endGroup; endGroup; ]
  218. 4.  Exp[- x*y/(x^2 + y^2)],  -3 <= x <= 3,  -3 <= y <= 3 .
  219. ^*)